#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e6 + 5;

void solve() {
    int id, m;
    cin >> id >> m;
    cout << id << " " << (m + 1) / 2 << endl;
    priority_queue<int> bq;
    priority_queue<int, vector<int>, greater<int>> sq;
    vector<int> ans;
    int num0;
    cin >> num0;
    bq.push(num0);
    ans.push_back(num0);
    for (int i = 1; i < m; i++) {
        int num;
        cin >> num;
        if (num <= bq.top())
            bq.push(num);
        else
            sq.push(num);
        if (bq.size() > sq.size() + 1) {
            sq.push(bq.top());
            bq.pop();
        } else if (sq.size() > bq.size()) {
            bq.push(sq.top());
            sq.pop();
        }
        if ((i + 1) % 2 == 1) {
            ans.push_back(bq.top());
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        if (i != 0) {
            if (i % 10 == 0)
                cout << endl;
            else
                cout << " ";
        }
        cout << ans[i];
    }
    cout << endl;
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int p;
    cin >> p;
    while (p--) solve();

    return 0;
}